<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" charset="utf-8">
	function sendForm(){
		var hobbyChk = document.form1.hobby;//checkbox 배열
		var cnt=0;
		for(var idx=0; idx<hobbyChk.length; idx++){
			if(hobbyChk[idx].checked){
				cnt++;
			}//checkbox객체.cheked->true(체크됐으면)||false(체크 안됐으면)
			
		}
		if(cnt==0){
			alert("취미를 선택하세요");
		}else{
			document.form1.submit();
		}
	}
		function checkAll(){
			var chk = document.form1.allchk.checked;
			var hobbyChk = document.form1.hobby;
			for(var idx =0; idx<hobbyChk.length; idx++){
				hobbyChk[idx].checked = chk;
			}
		}
		//라디오 버튼 체크 : 라디오체크.checked - true(체크) || false
		var gender = document.form1.gender;
		var cnt2 = 0;
		for(var i =0; i<gender.length; i++){
			if(gender[i].checked){
				cnt2++;
			}
			if(!cnt2){//cnt2==0이냐고 묻는거랑 같음
				alert("성별을 선택하세요");
				}else{
					document.form1.submit();
				}
		}
</script>
</head>
<body>
<form name = "form1">
	취미를 선택하세요(1개 이상)<br>
	<label>당구 <input type="checkbox" name="hobby" value="dangu"></label>
	<label>축구 <input type="checkbox" name="hobby" value="soccer"></label>
	<label>섹스 <input type="checkbox" name="hobby" value="sex"></label>
	<label>성교 <input type="checkbox" name="hobby" value="sexulrelationship"></label>
	<label>오입질 <input type="checkbox" name="hobby" value="intercore"></label><br>
	<label>전체 체크<input type="checkbox" name="allchk" onclick=checkAll();></label>
	<br>
	성별선택<br>
	남 : <input type="radio" name="gender" value="male">
	여 : <input type="radio" name="gender" value="female">
	
	<input type="button" value="전송" onclick="sendForm();">	
</form>
</body>
</html>